package com.yonggle.springbootdemo.config;

import com.github.pagehelper.PageInfo;
import com.yonggle.springbootdemo.model.User;
import com.yonggle.springbootdemo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/user")
@RestController
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping(value = "", method = RequestMethod.POST)
    public Boolean createUser(String user, String pswd) {
        return userService.createUser(user, pswd);
    }

    @RequestMapping(value = "/{userId}", method = RequestMethod.GET)
    public User getUser(Long userId) {
        return userService.getUserById(userId);
    }

    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public PageInfo createUser(Integer pageNum, Integer pageSize, String order) {
        return userService.listUserPage(pageNum, pageSize, order);
    }
}